package homework.day01;

public class Test01 {
    public static void main(String[] args) {

            String fileName1 = "logo.png";//要png
            String fileName2 = "jquery.1.1.2.js";//要js

            String ext = getExtByName(fileName1);
            System.out.println(ext);//png
            ext = getExtByName(fileName2);
            System.out.println(ext);//js

    }

    public static String getExtByName(String name) {
       //找到. 所在的位置
        int index = name.lastIndexOf(".");
        //从. 的下一个位置开始截取子字符串
        String  ext = name.substring(index+1);
        return ext;
    }

}

